<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
	<meta http-equiv="Content-Type" content="text/html;charset="UTF-8" />
	<title>登录页面</title>
	<link rel="stylesheet" href="css/prettify.css" />
    <link rel="stylesheet" href="css/bootstrap.min.css" />
   	<link rel="stylesheet" href="css/docs.css" />
    <script type="text/javascript" src="js/jquery.js"></script>
   	<style type="text/css" >
   	span{
   		color:red;
   	}
   </style>
</head>
<body>
	<div class="container">
		  <div class="hero-unit">
		  
		  <c:choose>
			<c:when test="${param.code=='1001'}">
				<div style="color:red;">验证码错误</div>
			</c:when>
			<c:when test="${param.code=='1002'}">
				<div style="color:red;">请先登录</div>
			</c:when>
			<c:when test="${param.code=='1003'}">
				<div style="color:red;">此用户不存在</div>
			</c:when>
			<c:when test="${param.code=='1004'}">
				<div style="color:red;">用户名或密码错误</div>
			</c:when>
			<c:when test="${param.code=='1005'}">
				<div style="color:red;">重置失败</div>
			</c:when>
		</c:choose>
		  
		  
            <h1>Hello,Welcome !</h1>
            <form class="well" action="login.jspx" method="post" id="myform">
		        <label>用户名：</label>
		        <input type="text" placeholder="用户名不可不填和只填空格"id="name" name="username"/><span id="name_error"></span>
		        <label>密码：</label>
		        <input type="password" placeholder="密码请不要填写常用字符" name="password" id="pwd"/><span id="pwd_error"></span><br/>
		        <div id="imgDiv">
		        	<img src="jcaptcha.jpg" id="img"/>
		        </div>
		         <label>输入验证码：</label>
	      		 <input type="text" name="captcha"placeholder="不区分大小写" value="" id="captcha"/><span id="captcha_error"、></span><br/>
		        <button type = "button" id="btn" class="btn btn-primary">登录</button>
      		</form> 
          </div>
 	</div>
	<script type="text/javascript" >
		$(document).ready(function(){
		
			$("#name").keydown(function(){
				$("#name_error").html("");
			});
			$("#pwd").keydown(function(){
				$("#pwd_error").html("");
			});
			$("#captcha").keydown(function(){
				$("#captcha_error").html("");
			});
			$("#imgDiv").click(function(){
				$("#img").attr("src","jcaptcha.jpg");
			});
			$("#btn").click(function(){
				var name = $("#name").val();
				var pwd = $("#pwd").val();
				var captcha = $("#captcha").val();
				if(name.trim()==null || name.trim()==""){
					$("#name").focus();
					$("#name_error").html("请输入用户名：");
					return ;
				}
				if(pwd==null || pwd==""){
					$("#pwd").focus();
					$("#pwd_error").html("请输入密码：");
					return ;
				}
				if(captcha==null||captcha==""){
					$("#captcha").focus();
					$("#captcha_error").html("请输入验证码：");
					return ;
				}
				$("#myform").submit();
			});
		});
	
	</script>
	
</body>
</html>